# 图像增强脚本
# 保护提取、复制、aurgment增强、PIL增强
import argparse
def clearData(path):
    try:
        import shutil
        shutil.rmtree(path)
    except Exception  as e :
        print(e)
        
# 全部基于jsonFile目录下创建输出
def handleImage():
    # 使用json2DateSetUtils.py对labme转换的数据进行批量提取图片和提取标注图片
    print('+++++++++++++++++++++开始：批量提取图片和提取标注图片++++++++++++++++++++++++++++++')
    # parser = argparse.ArgumentParser()
    # parser.add_argument('json_file')
    # args = parser.parse_args()
    # json_file = args.json_file
    json_file='D:\wuxixian\HYM\demo\\rawImage\out'
    
    import json2DateSetUtils
    outFile=json2DateSetUtils.main(json_file)
    
    # 运行j2DS_copyFile.py把图片和标注图片分别提取到各自目录raw、gt
    print('+++++++++++++++++++++开始：别提取到各自目录raw、gt++++++++++++++++++++++++++++++')
    import j2DS_copyFile
    j2DS_copyFile.CopyFileParams['json_file']=outFile
    j2DS_copyFile.CopyFileParams['outFilepath']=json_file
    rawPath,gtPath=j2DS_copyFile.handle()
    
    # 运行综合增强函数得到增强图片
    print('+++++++++++++++++++++开始：运行综合增强函数得到增强图片++++++++++++++++++++++++++++++')
    import augmentorUtils
    augmentorUtils.AugParas['prePath']=json_file
    augmentorUtils.AugParas['RawPath']=rawPath
    augmentorUtils.AugParas['GtPath']=gtPath
    augmentorUtils.AugParas['count']=50
    enhancePath=augmentorUtils.augmentor()
    
    import dataPILUtils
    dataPILUtils.PILParmas['RawPath']=rawPath
    dataPILUtils.PILParmas['GtPath']=gtPath
    dataPILUtils.PILParmas['RawPathOut']=enhancePath
    dataPILUtils.PILParmas['GtPathOut']=enhancePath
    dataPILUtils.PILParmas['count']=30
    dataPILUtils.handle()
    print('+++++++++++++++++++++结束：全部完成++++++++++++++++++++++++++++++')

if __name__ == '__main__':
    handleImage()